import numpy as np

from brushtools import AllTools

# The information about a sound project, passed to the audio thread as well as to widgets
class Project:
    def __init__(self, data):
    	data = data
        self.sample = data
        self.originalSample = [np.copy(s) for s in self.sample] # save a copy

        # This will be used to be able to zoom in and out on different regions
        self.sampleRange = [0, len(self.sample[0])]

        # The playback position, updated by the audio thread
        self.samplePosition = 0

        # So stuff don't break
        self.currentTool = AllTools[0]

        self.spectrogram = False

    def GetInterleavedSample(self):
        c = np.empty(sum([len(c) for c in self.sample]), dtype=float)
        nchans = len(self.sample)
        for i in range(nchans):
            c[i::nchans] = self.sample[i]
        return c